<?php 
function loginUser($tablename,$flduname,$fldpwd,$flduId,$valuname,$valpwd,$md5flag="true",$session_id,$session_name,$redirect_url_true,$redirect_url_false)
{
if($md5flag=='true')
$valpwd=md5($valpwd);
$selectQuery="SELECT * FROM ".$tablename." WHERE ".$flduname."='".$valuname."' AND ".$fldpwd."='".$valpwd."'";
$selectExe=mysql_query($selectQuery) or die ( "SELECTION ERROR : ".mysql_error());
if(mysql_num_rows($selectExe)>0)
{
	$arrayValue=mysql_fetch_assoc($selectExe);
	//$dbusername=$selectArray[$flduname];
	//$dbpassword=$arrayValue[$fldpwd];
	$dbuserId=$arrayValue[$flduId];
	
	
	
		$returnValue=setCookiee($session_id,$dbuserId,$session_name,$arrayValue,$redirect_url_true);
}
else
{
	$_SESSION['error']='Username and Password Invalid!!';
	redirectPath($redirect_url_false);
	
	}
}

function setCookiee($session_id,$dbuserId,$session_name,$arrayValue,$redirect_url_true)
{
	$_SESSION[$session_id]=$dbuserId;
	$_SESSION[$session_name]=$arrayValue;
	redirectPath($redirect_url_true);
}
function redirectPath($redirect_url)
{
header("location:".$redirect_url);
}
?>
